import com.vhly.util.DeviceInfo;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import java.util.Vector;

final class cls_f extends cls_w {

    private cls_u ao;
    int a;
    int fld_b_int;
    private int ap;
    private int aq;
    int c;
    int d;
    int e;
    int f;
    int g;
    private int ar;
    private int as;
    private int at;
    private int au;
    private int av;
    private Vector aw;
    private cls_l ax;
    int h[];
    int i[];
    int j[];
    private int ay;
    private int az;
    private long aA;
    private long aB;
    private long aC;
    private boolean aD;
    private boolean aE;
    boolean k;
    private boolean aF;
    cls_aa l;
    cls_aa m;
    cls_aa n;
    cls_aa o;
    cls_aa p;
    private String aG;
    cls_d q;
    Image img40;
    Image img43;
    Image img44;
    Image img63;
    Image img100;
    Image img53;
    Image img54;
    cls_u y;
    cls_u z;
    cls_u A;
    cls_u B;
    cls_k C;
    cls_k D;
    cls_k E;
    cls_a F;
    private int aH[][] = {
            {
                    0, 96, 0, 1
            }, {
                    0, 96, 0, 1
            }, {
                    128, 256, 2, 7
            }, {
                    64, 64, 1, 7
            }, {
                    64, 96, 1, 7
            }, {
                    0, 0, 1, 7
            }, {
                    128, 96, 2, 4
            }, {
                    64, 64, 1, 6
            }, {
                    128, 96, 2, 4
            }, {
                    0, 256, 0, 7
            }, {
                    0, 256, 0, 7
            }, {
                    128, 256, 0, 7
            }
    };
    int G[][] = {
            {
                    232
            }, {
                    233
            }, {
                    230
            }
    };

    cls_f(MainThread thread) {
        super(thread);
        aw = new Vector();
        ax = new cls_l();
        j = new int[3];
        ao = thread.bL;
        if (thread.recordManager.u == 0)
            thread.recordManager.u = 5;
    }

    final void a(int i1) {
        img40 = null;
        img43 = null;
        img53 = null;
        img63 = null;
        img54 = null;
        img44 = null;
        img100 = null;
        B = null;
        D = null;
        C = null;
        E = null;
        A = null;
        F = null;
        super.mainThread.j = null;
        if (i1 == 2)
            super.mainThread.c();
    }

    final void a(cls_d d1) {
        q = d1;
        ay = q.H;
        az = q.B;
        do
            d = ++d % 12;
        while (!k && b(d) != 0);
    }

    final void a_(Graphics g1) {
        if (f != e) {
            i();
            f = e;
        }
        l.b();
        m.b();
        n.b();
        int i1 = MainThread.c(l.a);
        int j1 = MainThread.c(l.b);
        g1.setClip(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
        g1.setColor(0x264150);
        g1.fillRoundRect(7, j1 - 3, 142, 92, 6, 6);
        g1.setColor(0x52a7d0);
        g1.fillRoundRect(9, j1 - 1, 138, 88, 6, 6);
        g1.setColor(0x396575);
        g1.fillRoundRect(10, j1, 136, 86, 6, 6);
        if (e > 0)
            D.a(g1, DeviceInfo.DEVICE_SCREEN_WIDTH, 0, e - 1 >> 1, 24);
        for (int k1 = 0; k1 < 3; k1++)
            if (k1 == ar || e == 5)
                E.a(g1, 154, (145 - E.d) + k1 * E.d, k1 + 3, 10);
            else
                E.a(g1, 154, (145 - E.d) + k1 * E.d, k1, 10);

        label0:
        switch (e) {
            default:
                break;

            case 1:
                int l1 = 0;
                for (int j3 = 0; j3 < 4; j3++) {
                    for (int j4 = 0; j4 < h.length; j4++) {
                        if (j4 == 0) {
                            B.a(g1, i1 + i[j3], j1 + h[j4], j3, 0, 6);
                            continue;
                        }
                        int i6;
                        if ((i6 = b(l1)) == 0)
                            A.a(g1, i1 + i[j3], j1 + h[j4], l1, 0, 6);
                        else if (i6 == 2)
                            y.a(g1, i1 + i[j3], j1 + h[j4], l1, 0, 6);
                        else
                            z.a(g1, i1 + i[j3], j1 + h[j4], l1, 0, 6);
                        l1++;
                    }

                }

                g1.setColor(0x6b9aa5);
                int k3 = i[1] - (i[0] + z.f) >> 1;
                for (int k4 = 1; k4 < 4; k4++)
                    g1.drawLine(i1 + (i[k4] - k3), j1 + c, i1 + (i[k4] - k3), j1 + h[h.length - 1]);

                super.mainThread.a(g1, ao, y.g >> 1, i[a] + (y.f >> 1), h[fld_b_int + 1] - MainThread.c(Math.abs(l.d - l.b)));
                break;

            case 2:
                int i2 = j1 + 6;
                super.mainThread.p.a(g1, super.mainThread.strs[199], 79, i2, 17);
                a(g1, super.mainThread.strs[205], i2, 80 - super.mainThread.p.n, 122, l);
                g1.setClip(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
                g1.drawImage(img44, 58, DeviceInfo.DEVICE_SCREEN_HEIGHT - super.mainThread.img24.getHeight(), 3);
                int l3 = q.L[ar].h;
                int l4 = q.L[ar].i;
                ao.a(g1, l3 - 35, l4, 12, 0, 3);
                ao.a(g1, l3 + 35, l4, 4, 0, 3);
                l3 = 154 - E.c;
                l4 = (145 - E.d) + ar * E.d;
                int j6 = 0;
                i2 = 0;
                do {
                    if (i2 >= 3)
                        break label0;
                    if ((aH[d][3] & 1 << i2) != 0 && ++j6 > 1) {
                        ao.a(g1, l3, l4 - 10, 8, 0, 10);
                        ao.a(g1, l3, l4 + 10, 0, 0, 10);
                        break label0;
                    }
                    i2++;
                } while (true);

            case 3:
                int j2 = j1 + 6;
                super.mainThread.p.a(g1, super.mainThread.strs[200], 79, j2, 1);
                int i5 = img43.getWidth();
                int k6 = ((DeviceInfo.DEVICE_SCREEN_WIDTH - i5) * 9) / 20;
                j2 = i1 + k6;
                for (int i4 = 0; i4 < 3; i4++) {
                    i1 = j1 + h[i4 + 1];
                    C.a(g1, j2, i1, i4, 10);
                    g1.setColor(0xa8a500);
                    g1.drawRect(j2 + 3, i1 - 3, 5 * j[i4], 6);
                    g1.setColor(0xf9fc01);
                    g1.fillRect(j2 + 3 + 1, (i1 - 3) + 1, 5 * j[i4] - 1, 5);
                    g1.drawImage(img43, j2, j1 + h[i4 + 1], 6);
                }

                j2 += j[ar] * 5 - 2;
                i1 = j1 + h[ar + 1];
                super.mainThread.a(g1, ao, 5, j2, i1 - MainThread.c(Math.abs(l.d - l.b)));
                j2 = q.L[ar].h;
                i1 = q.L[ar].i;
                ao.a(g1, j2 - 35, i1, 12, 0, 3);
                ao.a(g1, j2 + 35, i1, 4, 0, 3);
                j2 = 154 - E.c;
                i1 = (145 - E.d) + ar * E.d;
                ao.a(g1, j2, i1 - 10, 8, 0, 10);
                ao.a(g1, j2, i1 + 10, 0, 0, 10);
                break;

            case 4:
                int k2 = j1 + 6;
                super.mainThread.p.a(g1, super.mainThread.strs[201], 79, k2, 1);
                char c1 = aE ? '\313' : '\314';
                a(g1, super.mainThread.strs[c1], k2, 80 - super.mainThread.p.n, 122, l);
                g1.setClip(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
                if (aE) {
                    int l2 = 10 + super.mainThread.Q % 4;
                    int j5 = q.L[ar].h + 35;
                    int l6 = q.L[ar].i;
                    ao.a(g1, j5, l6 - l2, 8, 0, 3);
                    ao.a(g1, j5, l6 + l2, 0, 0, 3);
                } else {
                    int k5 = q.L[ar].h;
                    int i7 = q.L[ar].i;
                    ao.a(g1, k5 - 35, i7, 12, 0, 3);
                    ao.a(g1, k5 + 35, i7, 4, 0, 3);
                    k5 = 154 - E.c;
                    i7 = (145 - E.d) + ar * E.d;
                    ao.a(g1, k5, i7 - 10, 8, 0, 10);
                    ao.a(g1, k5, i7 + 10, 0, 0, 10);
                }
                break;

            case 5:
                int i3 = j1 + 6;
                super.mainThread.p.a(g1, super.mainThread.strs[202], 79, i3, 17);
                int l5 = img43.getWidth();
                int j7 = ((DeviceInfo.DEVICE_SCREEN_WIDTH - l5) * 9) / 20;
                g1.drawImage(img53, i1 + j7 + 3, j1 + h[1], 6);
                for (i3 = 0; i3 < 10; i3++) {
                    g1.setColor(super.mainThread.cE[i3][24]);
                    g1.drawRect(i1 + j7 + i3 * 10 + 3, (j1 + h[2]) - 3, 10, 6);
                    g1.setColor(super.mainThread.cE[i3][30]);
                    g1.fillRect(i1 + j7 + i3 * 10 + 3 + 1, ((j1 + h[2]) - 3) + 1, 8, 5);
                }

                for (i3 = 0; i3 < 10; i3++) {
                    g1.setColor(super.mainThread.cE[i3][24]);
                    g1.drawRect(i1 + j7 + i3 * 10 + 3, (j1 + h[3]) - 3, 10, 6);
                    g1.setColor(super.mainThread.cE[i3][31]);
                    g1.fillRect(i1 + j7 + i3 * 10 + 3 + 1, ((j1 + h[3]) - 3) + 1, 8, 5);
                }

                for (i3 = 0; i3 < 3; i3++) {
                    C.a(g1, i1 + j7, j1 + h[i3 + 1], i3 + 3, 10);
                    g1.drawImage(img43, i1 + j7, j1 + h[i3 + 1], 6);
                }

                i3 = i1 + j7;
                g1.drawImage(img54, i3 + 10 * au, j1 + h[1], 6);
                g1.drawImage(img54, i3 + 10 * at, j1 + h[2], 6);
                g1.drawImage(img54, i3 + 10 * as, j1 + h[3], 6);
                i3 += 10 * ap + 7;
                i1 = j1 + h[aq + 1];
                super.mainThread.a(g1, ao, 5, i3, i1);
                break;
        }
        q.a(super.mainThread.ci);
    }

    final void b_(Graphics g1) {
//        int j2;
        int l1 = (m.b) >> 8;
        g1.setColor(0x264150);
        g1.fillRoundRect(8, l1 - 3, 160, 123, 6, 6);
        g1.setColor(0x52a7d0);
        g1.fillRoundRect(10, l1 - 1, 156, 121, 6, 6);
        g1.setColor(0x396575);
        g1.fillRoundRect(11, l1, 154, 120, 6, 6);
        if (e == 1) {
            int i1 = l1 + 3;
            super.mainThread.u.a(g1, super.mainThread.strs[130 + d], 14, i1, 4);
            String s1 = MainThread.a(super.mainThread.strs[142 + d], super.mainThread.strs[240]);
            a(g1, s1, i1, DeviceInfo.DEVICE_SCREEN_HEIGHT - (i1 + super.mainThread.u.n + super.mainThread.img24.getHeight()), 148, m);
            g1.setClip(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
        } else if (e == 3 || e == 4) {
            g1.setColor(0xffffff);
            g1.drawLine(q.L[0].h, q.L[0].i, q.L[2].h, q.L[2].i);
            for (int j1 = 0; j1 < 3; j1++) {
                if (aE && j1 == ar)
                    g1.setColor(0xff3615);
                else if (j1 == ar)
                    g1.setColor(0x1424ff);
                else
                    g1.setColor(0xffffff);
                MainThread.a(g1, q.L[j1].h, q.L[j1].i, 3 + j[j1] >> 1);
            }

        }
        int is1 = ((n.b) >> 8) + 14;
        int k1 = ((n.a) >> 8) + 24;
        g1.drawImage(img100, 149, ((n.b) >> 8) + 14 + 3 + img63.getHeight(), 20);
        g1.setColor(0x264150);
        g1.fillRoundRect(k1 - 3, is1 - 3, 155, 186, 6, 6);
        g1.setColor(0x52a7d0);
        g1.fillRoundRect(k1 - 1, is1 - 1, 153, 182, 6, 6);
        g1.setColor(0x396575);
        g1.fillRoundRect(k1, is1, 152, 180, 6, 6);
        g1.drawImage(img63, (n.a) >> 8, ((n.b) >> 8) + 14 + 3, 20);
        if (aD || n.f > 0) {
            if (104 + (super.mainThread.u.e(aG) >> 1) > DeviceInfo.DEVICE_SCREEN_HEIGHT - super.mainThread.img24.getHeight()) {
                int k2;
                int i2 = (n.a) >> 8;
//                cls_h h1 = super.I.a;
                super.I.a.l = i2;
                super.I.a.a(g1);
                return;
            }
            int l2;
            super.mainThread.u.a(g1, aG, 4 + ((n.a) >> 8) + 88 + 12, ((n.b) >> 8) + 14 + 90, 3);
        }
    }

    private void i() {
        if (e > 0 && e < super.mainThread.recordManager.u)
            e = super.mainThread.recordManager.u;
        int i1 = Math.max(super.mainThread.recordManager.d / 3 != 0 ? super.mainThread.recordManager.d / 3 + 1 : super.mainThread.recordManager.d - 1, 0);
        if (aD)
            if (e == 0) {
                if (g == 0) {
                    super.I.a = new cls_h(super.mainThread, (short) 0, (short) 0, (short) 6, (short) 2, 2);
//                    int k1 = 0x6b9aa5;
//                    cls_h h2 = super.I.a;
                    super.I.a.k = 0x6b9aa5;
                    super.I.a.v[0] = (short) G[i1][g];
//                    i1 = 24;
//                    cls_h h1 = super.I.a;
                    super.I.a.m = 24;
                    super.I.a.a("*");
                    super.I.a.a(super.I.a.v.length);
                    av = super.I.a.v[0];
                    return;
                } else {
                    super.I.a = new cls_h(super.mainThread, (short) 5, (short) 4);
                    return;
                }
            } else {
                super.I.a = new cls_h(super.mainThread, (short) 6, (short) 4);
                return;
            }
        switch (e) {
            default:
                break;

            case 0:
                j();
                super.I.a = new cls_h(super.mainThread, (short) 0, (short) 0, (short) 6, (short) 2, 5);
                break;

            case 1:
                m.b(0, 88, 6);
                l.b(0, 0, 6);
                n();
                super.I.a = new cls_h(super.mainThread, (short) 0, (short) 0, (short) 5, (short) 1, 5);
                aw.removeAllElements();
                break;

            case 2:
                if (f == 1) {
                    ar = aH[d][2];
                } else {
                    int j1 = 0;
                    do {
                        if (j1 >= 3)
                            break;
                        if (q.L[j1] == ax.j) {
                            ar = j1;
                            break;
                        }
                        j1++;
                    } while (true);
                }
                m.b(0, DeviceInfo.DEVICE_SCREEN_HEIGHT, 6);
                n();
                super.I.a = new cls_h(super.mainThread, (short) 0, (short) 0, (short) 5, (short) 4, 5);
                break;

            case 3:
                if (super.mainThread.recordManager.u == 3) {
                    l.b(0, 0, 6);
                    super.I.a = new cls_h(super.mainThread, (short) 0, (short) 0, (short) 5, (short) 1, 5);
                } else {
                    super.I.a = new cls_h(super.mainThread, (short) 0, (short) 0, (short) 5, (short) 4, 5);
                }
                break;

            case 4:
                aE = false;
                m.b(0, DeviceInfo.DEVICE_SCREEN_HEIGHT, 6);
                super.I.a = new cls_h(super.mainThread, (short) 0, (short) 0, (short) 5, (short) 4, 5);
                break;

            case 5:
                au = q.K;
                at = q.g;
                as = q.f;
                if (super.mainThread.recordManager.u == 5) {
                    l.b(0, 0, 6);
                    super.I.a = new cls_h(super.mainThread, (short) 0, (short) 0, (short) 3, (short) 1, 5);
                } else {
                    super.I.a = new cls_h(super.mainThread, (short) 0, (short) 0, (short) 3, (short) 4, 5);
                }
                break;
        }
        super.I.a.fld_b_int = 2;
//        int l1 = 0x6b9aa5;
//        cls_h h3 = super.I.a;
        super.I.a.k = 0x6b9aa5;
        super.I.a.v[0] = (short) av;
        super.I.a.a("*");
        super.I.a.a(super.I.a.v.length);
    }

    final void a(int i1, int j1) {
        if (aD) {
            if ((i1 & 0x100000) != 0 || (i1 & 0x20) != 0)
                if (e == 0) {
                    int k1 = super.mainThread.recordManager.d / 3 != 0 ? super.mainThread.recordManager.d / 3 + 1 : super.mainThread.recordManager.d - 1;
                    if (++g >= G[k1].length) {
                        e++;
                        j();
                    }
                    super.I.a = new cls_h(super.mainThread, (short) 5, (short) 4);
                    return;
                } else {
                    i();
                    j();
                    return;
                }
            if ((i1 & 0x40000) != 0 || (i1 & 0x40) != 0) {
                if (e == 0) {
                    if (--g < 0) {
                        e++;
                        j();
                        return;
                    }
                    if (g == 0) {
                        super.I.a = new cls_h(super.mainThread, (short) 5, (short) 2);
                        return;
                    }
                } else {
                    j();
                    return;
                }
            } else if ((i1 & 0x202) != 0) {
                if (--super.I.a.g < 0) {
                    super.I.a.g = 0;
                    return;
                }
            } else if ((i1 & 0x8004) != 0 && ++super.I.a.g > super.I.a.o) {
                super.I.a.g = super.I.a.o;
                return;
            }
        } else {
            switch (e) {
                case 1:
                    if ((i1 & 0x202) != 0) {
                        if (--fld_b_int < 0)
                            fld_b_int = 2;
                        d = a * 3 + fld_b_int;
                        n();
                    } else if ((i1 & 0x8004) != 0) {
                        fld_b_int = ++fld_b_int % 3;
                        d = a * 3 + fld_b_int;
                        n();
                    } else if ((i1 & 0x808) != 0) {
                        if (--a < 0)
                            a = 3;
                        d = a * 3 + fld_b_int;
                        n();
                    } else if ((i1 & 0x2010) != 0) {
                        a = ++a % 4;
                        d = a * 3 + fld_b_int;
                        n();
                    }
                    if ((i1 & 0x20000) != 0 || (i1 & 0x1020) != 0) {
                        int l1;
                        if ((b(d)) == 0) {
                            ar = aH[d][2];
                            q.a(ar, 1 << d, aH[d][0], 0);
                            q.H |= 1 << d;
                            super.mainThread.a(q, 2, 1 << d);
                            f(0);
                            k();
                            e++;
                        }
                        return;
                    }
                    break;

                case 2:
                    if ((i1 & 0x202) != 0) {
                        do
                            if (--ar < 0)
                                ar = 2;
                        while ((aH[d][3] & 1 << ar) == 0);
                        ax.j = q.L[ar];
                    } else if ((i1 & 0x8004) != 0) {
                        do
                            ar = ++ar % 3;
                        while ((aH[d][3] & 1 << ar) == 0);
                        ax.j = q.L[ar];
                    } else if ((i1 & 0x1020) != 0) {
                        if (!l()) {
                            q.a(ar, 1 << d, ax.b, 0);
                            k();
                            int i2 = 16;
                            while (!f(i2)) {
                                i2 += 16;
                            }
                        }
                    } else if ((i1 & 0x80) != 0)
                        if (aw.size() > 1) {
                            q.J.removeElement(aw.lastElement());
                            aw.removeElement(aw.lastElement());
                            if (!aw.isEmpty())
                                ax = (cls_l) aw.lastElement();
                            else
                                ax = (cls_l) q.J.lastElement();
                        } else {
                            e = 1;
                            m();
                        }
                    break;

                case 3:
                    if ((i1 & 0x202) != 0) {
                        if (--ar < 0)
                            ar = 2;
                    } else if ((i1 & 0x8004) != 0)
                        ar = ++ar % 3;
                    else if ((i1 & 0x808) != 0 || (i1 & 0x2010) != 0) {
                        int j2 = ar != 0 ? ar - 1 : 2;
                        int k2 = ar != 2 ? ar + 1 : 0;
                        int l2 = Math.min(j2, k2);
                        j2 = Math.max(j2, k2);
                        if ((i1 & 0x808) != 0) {
                            if (j[ar] > 1) {
                                j[ar]--;
                                j[l2]++;
                            }
                            if (j[ar] > 1) {
                                j[ar]--;
                                j[j2]++;
                            }
                        } else {
                            if (j[l2] > 1) {
                                j[ar]++;
                                j[l2]--;
                            }
                            if (j[j2] > 1) {
                                j[ar]++;
                                j[j2]--;
                            }
                        }
                        q.L[ar].c = j[ar] * 5;
                        q.L[l2].c = j[l2] * 5;
                        q.L[j2].c = j[j2] * 5;
                        q.a();
                    } else if ((i1 & 0x1020) != 0)
                        e++;
                    break;

                case 4:
                    if ((i1 & 0x202) != 0) {
                        if (!aE && --ar < 0)
                            ar = 2;
                    } else if ((i1 & 0x8004) != 0) {
                        if (!aE)
                            ar = ++ar % 3;
                    } else if ((i1 & 0x1020) != 0)
                        aE = !aE;
                    break;

                case 5:
                    if ((i1 & 0x2010) != 0)
                        ap = ++ap % 10;
                    else if ((i1 & 0x808) != 0) {
                        if (--ap < 0)
                            ap = 9;
                    } else if ((i1 & 0x202) != 0) {
                        if (--aq < 0)
                            aq = 2;
                    } else if ((i1 & 0x8004) != 0)
                        aq = ++aq % 3;
                    else if ((i1 & 0x1020) != 0)
                        if (aq == 0) {
                            au = ap;
                            q.K = ap;
                        } else if (aq == 1) {
                            at = ap;
                            q.g = at;
                            super.mainThread.a(q, 6, 0);
                        } else if (aq == 2) {
                            as = ap;
                            q.f = as;
                            super.mainThread.a(q, 6, 0);
                        }
                    break;
            }
            if ((i1 & 0x20000) != 0) {
                if (++e >= 6) {
                    q.B = az;
                    if (super.mainThread.recordManager.q) {
                        if (super.mainThread.recordManager.u == 5)
                            super.mainThread.recordManager.u = 3;
                        else
                            super.mainThread.recordManager.u = 1;
                        super.mainThread.recordManager.q = false;
                        super.mainThread.k(0);
                    } else {
                        super.mainThread.gameState = 7;
                        super.mainThread.cs.a = MainThread.b(256);
                        super.mainThread.cs.a(0, 0, 0L, MainThread.bP);
                    }
                }
            } else if ((i1 & 0x40000) != 0) {
                if (--e == 1)
                    m();
                if (e < super.mainThread.recordManager.u) {
                    e = super.mainThread.recordManager.u;
                    super.mainThread.e();
                }
            } else if ((i1 & 0x40) != 0)
                super.mainThread.e();
            else if ((i1 & 0x100000) != 0) {
                j();
                if (e == 0)
                    e++;
            } else if ((i1 & 0x80000) != 0 && !k && super.vector.isEmpty()) {
                cls_u u1;
                (u1 = new cls_u(F)).n = q.o.a();
                u1.l = 80;
                u1.m = super.mainThread.bR;
                super.vector.addElement(u1);
                n();
            }
            switch (e) {
                default:
                    break;

                case 2:
                    if (MainThread.bP > aA) {
                        if ((j1 & 0x808) != 0)
                            f(16);
                        else if ((j1 & 0x2010) != 0)
                            f(-16);
                        if (j1 != 0) {
                            aA = MainThread.bP + 200L;
                            return;
                        }
                    }
                    break;

                case 4:
                    if ((j1 & 0x202) != 0) {
                        if (!aE)
                            break;
                        if (ar == 1) {
                            c(0, 10);
                            c(2, 10);
                            return;
                        } else {
                            c(ar, -10);
                            return;
                        }
                    }
                    if ((j1 & 0x8004) == 0 || !aE)
                        break;
                    if (ar == 1) {
                        c(0, -10);
                        c(2, -10);
                        return;
                    }
                    c(ar, 10);
                    break;
            }
        }
    }

    private void j() {
        aD = !aD;
        if (aD) {
            if (e == 0) {
                super.I.a = new cls_h(super.mainThread, (short) 5, (short) 2);
                int i1 = Math.max(super.mainThread.recordManager.d / 3 != 0 ? super.mainThread.recordManager.d / 3 + 1 : super.mainThread.recordManager.d - 1, 0);
                aG = MainThread.a(super.mainThread.strs[G[i1][g]], "*");
            } else {
                super.I.a = new cls_h(super.mainThread, (short) 6, (short) 4);
                aG = super.mainThread.strs[DeviceInfo.DEVICE_SCREEN_HEIGHT + (e - 1)];
            }
            n();
            aG = new String(cls_b.a(aG));
            n.b(0, 0, 6);
            return;
        } else {
            n.b(149, 0, 6);
            i();
            return;
        }
    }

    private void c(int i1, int j1) {
        if (q.L[i1].b == 0)
            j1 = -j1;
        q.L[i1].a += j1;
        if (q.L[i1].a < 0)
            q.L[i1].a = 0;
        else if (q.L[i1].a > 100)
            q.L[i1].a = 100;
        q.a();
    }

    final int b(int i1) {
        if ((ay & 1 << i1) != 0)
            return 2;
        return i1 % 3 != 0 && (ay & 1 << i1 - 1) == 0 ? 1 : 0;
    }

    private void k() {
        for (int i1 = q.J.size() - 1; i1 >= 0; i1--) {
            ax = (cls_l) q.J.elementAt(i1);
            if (ax.d == 1 << d) {
                aw.addElement(ax);
                q.d();
                return;
            }
        }

    }

    private boolean l() {
        int i1 = 0;
        for (int j1 = 0; j1 < q.J.size(); j1++) {
            cls_l l1;
            if ((l1 = (cls_l) q.J.elementAt(j1)).d == ax.d && l1.b == ax.b && l1.j == ax.j && ++i1 > 1)
                return true;
        }

        return false;
    }

    private boolean f(int i1) {
        if (i1 != 0) {
            int j1 = ((aH[d][0] - (aH[d][1] >> 1)) + 256) % 256;
            int k1 = aH[d][0] + (aH[d][1] >> 1) % 256;
            if (aH[d][1] == 256)
                ax.b += i1;
            else if (j1 < k1) {
                if ((ax.b + i1) % 256 >= j1 && (ax.b + i1) % 256 <= k1)
                    ax.b += i1;
                else
                    return false;
            } else if (j1 > k1)
                if ((ax.b + i1) % 256 >= j1 || (ax.b + i1) % 256 <= k1)
                    ax.b += i1;
                else
                    return false;
        }
        ax.b = (ax.b + 256) % 256;
        return true;
    }

    final void c(int i1) {
        switch (i1) {
            case 1:
                do {
                    i1 = super.mainThread.j(12);
                    while (b(i1) != 0) {
                        i1 = (i1 + 1) % 12;
                    }
                } while (d == i1);
                d = i1;
                a = d / 3;
                fld_b_int = d % 3;
                if (super.mainThread.R != 3) {
                    ar = aH[d][2];
                    q.a(ar, 1 << d, aH[d][0], 0);
                    q.H |= 1 << d;
                    f(0);
                    k();
                }
                return;

            case 2:
                int i2 = -1;
                for (int j1 = 0; j1 < q.J.size(); j1++) {
                    cls_l l2;
                    if (((cls_l) q.J.elementAt(j1)).d == 1 << d) {
                        q.J.removeElementAt(j1--);
                        i2++;
                    }
                }

                int k1;
                do {
                    do
                        k1 = super.mainThread.j(3);
                    while ((aH[d][3] & 1 << k1) == 0);
                    if ((1 << d & 0x20) != 0)
                        i1 = 1;
                    else
                        i1 = 1 + super.mainThread.j(4);
                } while (i1 == i2 && k1 == ar);
                ar = k1;
                k1 = (i1 & 1) != 0 ? 0 : 16;
                int j2 = aH[d][0] + k1 + (i1 >> 1) * -32;
                for (int l1 = 0; l1 < i1; l1++) {
                    q.a(ar, 1 << d, (j2 + 256) % 256, 0);
                    k();
                    f(l1 << 5);
                }

                return;

            case 3:
                for (i1 = 0; i1 < 3; i1++)
                    j[i1] = 1;

                for (i1 = 0; i1 < 17; i1++) {
                    ar = super.mainThread.j(3);
                    j[ar]++;
                }

                for (i1 = 0; i1 < 3; i1++)
                    q.L[i1].c = j[i1] * 5;

                q.a();
                return;

            case 4:
                q.L[0].a = 100 / (1 + super.mainThread.j(10));
                q.L[2].a = 100 / (1 + super.mainThread.j(10));
                q.a();
                return;

            case 5:
                do {
                    au = super.mainThread.j(10);
                    at = super.mainThread.j(10);
                    as = super.mainThread.j(10);
                } while (au == q.K && at == q.g && as == q.f);
                q.K = au;
                q.g = at;
                q.f = ap = as;
                if (super.mainThread.R == 3)
                    super.mainThread.a(q, 6, 0);
                aq = 2;
                break;
        }
    }

    private void m() {
        int i1 = 1 << d;
        for (int j1 = 0; j1 < q.J.size(); j1++) {
            cls_l l1;
            if (((cls_l) q.J.elementAt(j1)).d == i1)
                q.J.removeElementAt(j1--);
        }

        q.H &= ~i1;
        super.mainThread.a(q, 4, i1);
    }

    private void n() {
        int i1;
        p.a = (((n.a) >> 8) + 24 + 3) << 8;
        p.b = (((n.b) >> 8) + 14 + 1) << 8;
        if (e == 1) {
            int j1;
            o.a = (14) << 8;
            o.b = (91 + super.mainThread.u.n) << 8;
        } else {
//            int k1;
            o.a = (18) << 8;
            o.b = (((l.b) >> 8) + 6 + super.mainThread.p.n) << 8;
        }
        aB = MainThread.bP;
        aF = false;
    }

    final void d(int i1) {
        super.d(i1);
        switch (i1) {
            case 8:
                super.J.d();
                super.J.a(0, true);
                super.mainThread.A = true;
                super.mainThread.am = super.mainThread.ck.H;
                if (super.mainThread.R == 3)
                    super.mainThread.j.i();
                break;
        }
    }

    final void c(Graphics g1) {
        for (int i1 = 0; i1 < super.vector.size(); i1++) {
            cls_u u1;
            int k1;
            int j1 = ((u1 = (cls_u) super.vector.elementAt(i1)).n.a - super.mainThread.ci.a) >> 8;
            k1 = (u1.n.b - super.mainThread.ci.b) >> 8;
            u1.a(g1, j1, k1, u1.b - 1, 0, 3);
            if (u1.b == u1.i >> 1 && !u1.o) {
                c(e);
                u1.o = true;
            }
            if (super.mainThread.bR - u1.m <= (long) u1.l)
                continue;
            if (++u1.b > u1.i)
                super.vector.removeElementAt(i1--);
            u1.m = super.mainThread.bR;
        }

    }

    private void a(Graphics g1, String s1, int i1, int j1, int k1, cls_aa aa1) {
        cls_aa aa2 = o;
//        aa1 = aa1;
//        g1 = k1;
        k1 = j1;
        j1 = i1;
//        i1 = s1;
//        s1 = g1;
//        g1 = this;
        boolean flag = aD && aa2 != this.p;
        boolean flag1 = Math.abs(aa1.b - aa1.d) < 50 && Math.abs(aa1.a - aa1.c) < 50;
        s1 = cls_b.a(s1);   // TODO i1 is what
        int i2 = k1 / ((this)).mainThread.u.n;
        int j2 = mainThread.u.e(s1) / mainThread.u.n;
        k1 = i2 * mainThread.u.n;
        if (!flag)
            if (j2 > i2 && flag1) {
                if (MainThread.bP > aB + 3000L) {
                    int l1 = (j2 - i2) * mainThread.u.n;
                    if (!aF) {
                        i2 = 15 * (l1 / mainThread.u.n);
                        aa2.a((aa2.a) >> 8, ((aa2.b) >> 8) - l1, i2);
                        this.aF = true;
                    }
                    if (aa2.b == aa2.d) {
                        if (MainThread.bP > aC + 3000L)
                            this.n();
                    } else {
                        aa2.c();
                        this.aC = MainThread.bP;
                    }
                }
            } else {
                this.n();
            }
        g1.setClip(0, j1 + mainThread.u.n, DeviceInfo.DEVICE_SCREEN_WIDTH, k1);
        boolean bl1 = aa1 != n ? false : true;
        i2 = (aa2.a) >> 8;
        if (bl1)
            i2 += 68;
        k1 = bl1 ? 17 : 20;
        if (flag1) {
            int k2;
            mainThread.u.a(g1, s1, i2, (aa2.b) >> 8, k1);
            return;
        } else {
            mainThread.u.a(g1, s1, i2, j1 + mainThread.u.n, k1);
            return;
        }
    }
}